var cons = require('consolidate');
var promise = require('bluebird');
var utils = promise
		.promisifyAll(require('/Users/Steve/tools/myGit/xNode/common/FooUtils.js'));

// var token = process.argv[2].trim();

var compressor = promise.promisifyAll(require('yuicompressor'));

var srcFile = '/Users/Steve/tools/myGit/xNode/common/compressor/YuiCompressorSrc.js';
var targerFile = '/Users/Steve/tools/myGit/xNode/common/compressor/YuiCompressorTarget.js';

utils.ensureFileAsync(targerFile).then(function(){
	return compressor.compressAsync(srcFile, {
		// Compressor Options:
		charset : 'utf8',
		type : 'js',
		nomunge : true,
		'line-break' : 80
	});
}).then(function(data) {
	utils.writeFileAsync(targerFile, data);
}).then(function(data) {
	console.log('compress success, see file:%s',targerFile);
}).catch(function(err){
	console.log('compress error:%',err);
});